﻿
/*
NAILSUPERSTORE ® COMPANY
 
[HISTORY]
Created By  	: NGUYEN VAN TY
Created Date	: 18/01/2010
Modified By     :
Modified Date   :
Note            :

*/

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using CommonTagTime.DataAccess;
using CommonTagTime.ModelObject;
namespace CommonTagTime.Business
{
    public class busZone
    {
        //------------------------------------------------
        //FIELD TABLE
        //------------------------------------------------

        public const string ZoneId = "ZoneId";
        public const string Name = "Name";
        public const string OrderBy = "OrderBy";
        public const string OrderDirection = "OrderDirection";
        public const string CurrentPage = "CurrentPage";
        public const string PageSize = "PageSize";
        public const string TotalRecords = "TotalRecords";
        public const string Condition = "Condition";


        private daoZone _objDao;
        //------------------------------------------------
        //PUBLIC
        //------------------------------------------------
        public busZone()
        {
            _objDao = new daoZone();
        }       
        public bool OrderDown(int _ZoneId)
        {
            bool result = _objDao.OrderDown(_ZoneId);
            if (result)
                clsCacheUtil.RemoveCacheWithPrefix("Zone_");
            return result;          
        }
        public bool OrderUp(int _ZoneId)
        {
            bool result = _objDao.OrderUp(_ZoneId);
            if (result)
                clsCacheUtil.RemoveCacheWithPrefix("Zone_");
            return result;              
        }
        public bool Active(int _ZoneId)
        {
            bool result = _objDao.Active(_ZoneId);
            if (result)
                clsCacheUtil.RemoveCacheWithPrefix("Zone_");
            return result;           
        }
        public bool DeActive(int _ZoneId)
        {
            bool result = _objDao.DeActive(_ZoneId);
            if (result)
                clsCacheUtil.RemoveCacheWithPrefix("Zone_");
            return result;                 
        }
        public bool Delete(int _ZoneId)
        {           
            bool result = _objDao.Delete(_ZoneId);
            if (result)
                clsCacheUtil.RemoveCacheWithPrefix("Zone_");
            return result;        
        }       
        public bool Insert(Zone objData)
        {
            bool result=_objDao.Insert(objData);
            if (result)
                clsCacheUtil.RemoveCacheWithPrefix("Zone_");            
            return result;
        }
        public bool Update(Zone objData)
        {
            bool result = _objDao.Update(objData);
            if (result)
                clsCacheUtil.RemoveCacheWithPrefix("Zone_");
            return result;          
        }
        public ZoneCollection List(int CategoryId)
        {
            string key = "Zone_List_" + CategoryId.ToString();
            ZoneCollection result = clsCacheUtil.GetCache(key) as ZoneCollection;
            if (result == null)
            {
                result = _objDao.List(CategoryId);
                clsCacheUtil.SetCache(key, result);
            }
            return result;
        }

        public ZoneCollection ListAll()
        {
            string key = "Zone_ListAll";
            ZoneCollection result = clsCacheUtil.GetCache(key) as ZoneCollection;
            if (result == null)
            {
                result = _objDao.ListAll();
                clsCacheUtil.SetCache(key, result);
            }
            return result;
        }
    }
}
